<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page session="false"%>
<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>admin</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        
        <link href="<c:url value="/resources/css/style.css" />" rel="stylesheet" type="text/css" />
        <link href="<c:url value="/resources/jqueryui/1.8/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />" rel="stylesheet" type="text/css" />

        <script src="<c:url value="/resources/jquery/jquery.js" />"></script>
        <script src="<c:url value="/resources/jqueryui/1.8/jquery-ui-1.8.16.custom.min.js" />"></script>
        <script src="<c:url value="/resources/jqueryui/1.8/jquery.ui.datepicker-zh-CN.js" />"></script>
        <script src="<c:url value="/resources/jquery/plugin/cookie/jquery.cookie.js" />"></script>
        <script src="<c:url value="/resources/scripts/html5.js" />"></script>
        
    </head>
    
    <script>
    $(document).ready(function(){
    	$('#checkboxSelectAll').click(function(){
    		if($(this).attr('checked')){
    			$('table tbody input:checkbox').prop('checked', 'checked');
    		}
    		else{
    			$('table tbody input:checkbox').prop('checked', '');
    		}
    	});
    });

    function editProduct(id){
        //var url = '<c:url value="/admin/product/edit?action=update&id="/>';
        //document.location.href = url + id;

        //var url = '<c:url value="/product/update"/>';
        //document.location.href = url;
    }

    function addProduct(){
        var url = '<c:url value="/product/update"/>';
        document.location.href = url;
    }
    function promoteProduct(id){
    	var url = '<c:url value="/admin/product/promote?action=promote&id="/>';
    	document.location.href = url + id;
    }
    function unpromoteProduct(id){
    	var url = '<c:url value="/admin/product/promote?action=unpromote&id="/>';
    	document.location.href = url + id;
    }
    function deleteProduct(id){
    	var url = '<c:url value="/admin/product/delete?action=delete&id="/>';
    	document.location.href = url + id;
    }
    function reload(){
    	document.location.href
    }
    </script>
    <body>
        <table class="table-list-style">
            <caption style="text-align:left">
                        <a id="btnAddNewProduct" style="float: right;" href="javascript:void(0);" onclick="javascript:addProduct()">发布新媒体</a>
            </caption>
            <thead align="left">
                <tr>
                    <th align="left"><input type="checkbox" id="checkboxSelectAll" /></th>
                    <th align="left" >媒体名称</th>
                    <th align="left">价格</th>
                    <!--th align="left" style="width:40%">Description</th-->
                    <th align="left">推广</th>
                    <th align="left">操作</th>
                </tr>
            </thead>
			<tbody>
			<c:forEach var="product" items="${products}">
			
				<tr>
				    <td><input type="checkbox" value="${product.id}"/></td>
					<td>${product.name}</td>
					<td>${product.price}/${product.unit}</td>
					<td>${product.promoteIndicator}</td>
					<!--td>${product.description}</td-->
					<td><a href="javascript:void(0);" onclick="javascript:editProduct('${product.id}');">编辑</a>, 
					    <a href="javascript:void(0);" onclick="javascript:deleteProduct('${product.id}')">删除</a>,
					    <a href="javascript:void(0);" onclick="javascript:promoteProduct('${product.id}')">产品推广</a>,
					    <a href="javascript:void(0);" onclick="javascript:unpromoteProduct('${product.id}')">解除推广</a></td>
				</tr>
			</c:forEach>
			</tbody>
            
        </table>
        <!--a id="btnDelCategory" href="javascript:void(0);">Delete selected</a-->
    </body>
</html>
